import 'package:app_base_page/app_base_page.dart';

/**
 *
 * @ProjectName:    manager_page
 * @ClassName:      teach_page
 * @Description:    dart类作用描述
 * @Author:         孙浩
 * @QQ:             243280864
 * @CreateDate:     2020/11/24 10:05 PM
 */
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';

import 'base_adapter.dart';
import 'base_page.dart';
import 'info_data.dart';

class TeachPage extends StatefulWidget {
  String imgPath;

  TeachPage(this.imgPath);

  @override
  _State createState() => _State();
}

class _State extends BasePage<TeachPage> {
  @override
  pageV() => false;

  List<InfoData> dataList = [
    InfoData("用人", """1.swot
    2.swot四象限
    3.分析"""),
    InfoData("育人",
        "工作是一个过程，做好工作是一个不断优化的过程，优化知识层级，优化人员配置。所以在团队组建时讲的人员培养应该是一个不断优化和进行的过程，从一个人会到大家会的过程"),
  ];

  @override
  Widget initPageBody(BuildContext c) => BaseMPage(
        widget.imgPath,
        (ctx, index) => buildItem(index),
        dataList.length,
        "用人育人",
        child: Padding(
          child: CustomScrollView(
            slivers: [
              buildTitle(),
              SliverToBoxAdapter(
                child: SizedBox(
                  height: 20,
                ),
              ),
              SliverToBoxAdapter(
                child: BaseAdapter(
                    -1,
                    InfoData("2.育人",
                        "工作是一个过程，做好工作是一个不断优化的过程，优化知识层级，优化人员配置。所以在团队组建时讲的人员培养应该是一个不断优化和进行的过程，从一个人会到大家会的过程")),
              )
            ],
            physics: ClampingScrollPhysics(),
          ),
          padding: EdgeInsets.symmetric(horizontal: 50, vertical: 30),
        ),
      );

  SliverToBoxAdapter buildTitle() {
    return SliverToBoxAdapter(
      child: Row(
        crossAxisAlignment: CrossAxisAlignment.start,
        children: [
          ConstrainedBox(
            constraints: BoxConstraints(minWidth: 250),
            child: Text(
              "1.用人",
              style: TextStyle(fontSize: 22, fontWeight: FontWeight.bold),
            ),
          ),
          SizedBox(
            width: 50,
          ),
          Expanded(
              child: GridView.builder(
                padding: EdgeInsets.all(0),
                  physics: NeverScrollableScrollPhysics(),
                  shrinkWrap: true,
                  itemCount: 4,
                  gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
                      crossAxisCount: 2,
                      crossAxisSpacing: 20,
                      childAspectRatio: 2 / 1,
                      mainAxisSpacing: 20),
                  itemBuilder: (ctx, index) {
                    Widget view;
                    switch (index) {
                      case 0:
                        view = Stack(
                          children: [
                            Positioned(
                              child: Column(
                                mainAxisAlignment: MainAxisAlignment.center,
                                children: [
                                  Text(
                                    "S",
                                    style: createTitleStyle(),
                                  ),
                                ],
                              ),
                              left: 0,
                              top: 0,
                              bottom: 0,
                            ),
                            Text(
                              "O",
                              style: createTitleStyle(),
                            ),
                            Center(
                              child: Text(
                                "优势+机会\n快速发展",
                                style: createBodyStyle(),
                                textAlign: TextAlign.center,
                              ),
                            )
                          ],
                          alignment: Alignment.topCenter,
                        );
                        break;
                      case 1:
                        view = Stack(
                          children: [
                            Text(
                              "T",
                              style: createTitleStyle(),
                            ),
                            Center(
                              child: Text(
                                "优势+威胁\n扬长避短",
                                style: createBodyStyle(),
                                textAlign: TextAlign.center,
                              ),
                            )
                          ],
                          alignment: Alignment.topCenter,
                        );
                        break;
                      case 2:
                        view = Stack(
                          children: [
                            Positioned(
                              child: Column(
                                mainAxisAlignment: MainAxisAlignment.center,
                                children: [
                                  Text(
                                    "W",
                                    style: createTitleStyle(),
                                    textAlign: TextAlign.center,
                                  ),
                                ],
                              ),
                              left: 0,
                              top: 0,
                              bottom: 0,
                            ),
                            Text(
                              "劣势+机会\n趋利避害",
                              style: createBodyStyle(),
                              textAlign: TextAlign.center,
                            )
                          ],
                          alignment: Alignment.center,
                        );
                        break;
                      case 3:
                        view = Stack(
                          children: [
                            Text("劣势+威胁\n快速发展/按兵不动", style: createBodyStyle(),textAlign: TextAlign.center,)
                          ],
                          alignment: Alignment.center,
                        );
                        break;
                    }
                    return Card(
                        child: Padding(
                          child: view,
                          padding: EdgeInsets.symmetric(
                              horizontal: 20, vertical: 10),
                        ),
                        elevation: 5,
                        shape: RoundedRectangleBorder(
                            borderRadius: BorderRadius.circular(15)));
                  }))
        ],
      ),
    );
  }

  buildItem(int index) => BaseAdapter(index, dataList[index]);

  TextStyle createTitleStyle() =>
      TextStyle(fontSize: 22, fontWeight: FontWeight.bold);

  TextStyle createBodyStyle() =>
      TextStyle(fontSize: 18, fontWeight: FontWeight.bold,letterSpacing: 3);
}
